cmake_minimum_required(VERSION 3.8)
project(Stewart_only_description)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 查找依赖
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(control_msgs REQUIRED)
find_package(ros2_control REQUIRED)
find_package(ros2_controllers REQUIRED)
find_package(gazebo_ros2_control REQUIRED)
find_package(hardware_interface REQUIRED)

# 包含头文件
include_directories(include)

install(
  DIRECTORY include/
  DESTINATION include/${PROJECT_NAME}
)

# C++节点
add_executable(stewart_inverse_kinematics 
src/stewart_inverse_kinematics.cpp
src/mldivide.cpp
)
ament_target_dependencies(stewart_inverse_kinematics
  rclcpp
  std_msgs
  sensor_msgs
)

# 安装C++节点
install(TARGETS
  stewart_inverse_kinematics
  DESTINATION lib/${PROJECT_NAME}
)

# 安装Python节点（无需setup.py）
ament_python_install_package(${PROJECT_NAME})

install(PROGRAMS
  scripts/position_control.py
  scripts/UDP_interface.py
  scripts/recorder.py
  scripts/main_logic.py
  DESTINATION lib/${PROJECT_NAME}
)

# 安装资源文件
install(DIRECTORY
  launch meshes urdf config world
  DESTINATION share/${PROJECT_NAME}/
)

ament_package()